package com.bootdo.common.utils;

import com.bootdo.market.dao.CommonDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class TaskUtil {
    @Autowired
    private CommonDao commonDao;

    @Scheduled(cron = "0 0 1 * * ? ")
    public void update() {
        List<Map<String, Object>> list = commonDao.getVaildChannelProduct();
        list.stream().forEach(stringObjectMap -> {
            stringObjectMap.put("historyDate", DateUtil.getCurrentDate());
            commonDao.insertVaildChannelProduct(stringObjectMap);
        });
    }
}
